home *** CD-ROM | disk | FTP | other *** search
/ Interactive CD-ROM & Web Magazine 6 / Interactive CD-ROM & Web Magazine 6.iso / mac / INTERACTIVE MAC / SHARED.DIR / 05121.ls < prev    next >
Encoding:
Text File  |  1996-04-05  |  3.7 KB  |  118 lines

  1. global guardaQui, pathSeparator, hd, netObj, cd
  2.  
  3. on checkMimeType riga
  4.   set docname to the pathName & "seealso" & pathSeparator & item 4 of line riga of guardaQui
  5.   set mimeType to item 2 of line riga of guardaQui
  6.   set mimeSubtype to item 3 of line riga of guardaQui
  7.   if the machineType <> 256 then
  8.     if mimeSubtype = "HTML" then
  9.       alert("Purtroppo questa funzione non ├¿ ancora implementata su Mac")
  10.     else
  11.       put docname into field 4000
  12.       copyToClipBoard(cast 4000)
  13.       set docname to the text of field 4000
  14.       open(hd & "launch")
  15.     end if
  16.   else
  17.     if mimeSubtype = "HTML" then
  18.       URLClicked(item 4 of line riga of guardaQui)
  19.     else
  20.       set baseFile to cd & pathSeparator & "IMM" & pathSeparator & "mimebase.cfg"
  21.       set configFile to hd & "mime.cfg"
  22.       viewDocument(mimeType, mimeSubtype, docname, configFile, baseFile)
  23.     end if
  24.   end if
  25. end
  26.  
  27. on viewDocument mimeType, mimeSubtype, documentName, configFile, baseFile
  28.   set newConfig to 0
  29.   set helperPath to GetConfigHelper(mimeType, mimeSubtype, configFile)
  30.   if helperPath = EMPTY then
  31.     set helperPath to GetBaseHelper(mimeType, mimeSubtype, baseFile)
  32.     if helperPath <> EMPTY then
  33.       if not netObj(mFileExist, helperPath) then
  34.         set helperPath to askHelper(mimeType, mimeSubtype, 1)
  35.         set newConfig to 1
  36.       end if
  37.     else
  38.       set helperPath to askHelper(mimeType, mimeSubtype, 1)
  39.       set newConfig to 1
  40.     end if
  41.   end if
  42.   if (helperPath <> EMPTY) and newConfig then
  43.     AddHelper(mimeType, mimeSubtype, helperPath, configFile)
  44.   end if
  45.   open(documentName, helperPath)
  46. end
  47.  
  48. on GetConfigHelper mimeType, mimeSubtype, configFile
  49.   set Obj to FileIO(mnew, "read", configFile)
  50.   if not objectp(Obj) then
  51.     set mimeConfig to EMPTY
  52.   else
  53.     set mimeConfig to Obj(mReadFile)
  54.     Obj(mdispose)
  55.   end if
  56.   set the itemDelimiter to TAB
  57.   set helperPath to EMPTY
  58.   repeat with counter = 1 to the number of lines in mimeConfig
  59.     set testedLine to line counter of mimeConfig
  60.     set testedType to item 1 of testedLine
  61.     set testedSubtype to item 2 of testedLine
  62.     if (testedType = mimeType) and (testedSubtype = mimeSubtype) then
  63.       set helperPath to item 3 of testedLine
  64.     end if
  65.   end repeat
  66.   return helperPath
  67. end
  68.  
  69. on GetBaseHelper mimeType, mimeSubtype, baseFile
  70.   set Obj to FileIO(mnew, "read", baseFile)
  71.   if not objectp(Obj) then
  72.     set mimeConfig to EMPTY
  73.   else
  74.     set mimeConfig to Obj(mReadFile)
  75.     Obj(mdispose)
  76.   end if
  77.   set the itemDelimiter to TAB
  78.   set helperPath to EMPTY
  79.   repeat with counter = 1 to the number of lines in mimeConfig
  80.     set testedLine to line counter of mimeConfig
  81.     set testedType to item 1 of testedLine
  82.     set testedSubtype to item 2 of testedLine
  83.     if (testedType = mimeType) and (testedSubtype = mimeSubtype) then
  84.       set helperPath to item 3 of testedLine
  85.     end if
  86.   end repeat
  87.   return helperPath
  88. end
  89.  
  90. on askHelper mimeType, mimeSubtype
  91.   set alertString to "Non hai configurato l'applicazione che visualizza i file "
  92.   set alertString to alertString & mimeType & "/" & mimeSubtype
  93.   set alertString to alertString & ". Per favore trova l'applicazione con cui visualizzare questo tipo di file."
  94.   alert(alertString)
  95.   return netObj(mGetPath, "Visualizzatore " & mimeType & "/" & mimeSubtype, "Applicazioni", "*.EXE")
  96. end
  97.  
  98. on AddHelper mimeType, mimeSubtype, helperPath, configFile
  99.   set Obj to FileIO(mnew, "read", configFile)
  100.   if not objectp(Obj) then
  101.     set mimeConfig to EMPTY
  102.   else
  103.     set mimeConfig to Obj(mReadFile)
  104.     Obj(mdispose)
  105.   end if
  106.   set Obj to FileIO(mnew, "write", configFile)
  107.   set newContent to mimeConfig & RETURN & mimeType & TAB & mimeSubtype & TAB & helperPath
  108.   Obj(mWriteString, newContent)
  109.   Obj(mdispose)
  110. end
  111.  
  112. on esci
  113.   go(1, cd & pathSeparator & "IMM" & pathSeparator & "quit.dir")
  114. end
  115.  
  116. on indietro
  117. end
  118.